class UFS:
    def __init__(self, n):
        self.n = n
        self.f = list(range(n + 1))

        self.size = [1] * (n + 1)
        self.dist = [0] * (n + 1)

    def is_root(self, a):
        return a == self.f[a]

    def find(self, a):
        if not self.is_root(a):
            f = self.f[a]

            self.f[a] = self.find(self.f[a])
            self.dist[a] += self.dist[f]

        return self.f[a]

    def union(self, a, b, d=0):  # a branch, b root
        root_a, root_b = self.find(a), self.find(b)

        if root_a != root_b:
            self.f[root_a] = root_b

            self.dist[root_a] = d
            self.size[root_b] += self.size[root_a]

    def is_connected(self, a, b):
        return self.find(a) == self.find(b)

    def get_roots(self):
        return [i for i in range(1, self.n + 1) if self.is_root(i)]

    def root_dist(self, a):
        self.find(a)
        return self.dist[a]

    def get_dist(self, a, b):
        if not self.is_connected(a, b):
            return -1

        return self.dist[a] - self.dist[b]

    def get_size(self, a):
        root = self.find(a)
        return self.size[root]


class Record:
    def __init__(self, ufs, pairs, destroy):
        self.ufs = ufs
        self.pairs = pairs
        self.destroy_set = set(destroy)

        self.pairs_dict = {}
        self.destroy_dict = {}

    def in_destroy(self, x):
        return x in self.destroy_set

    def count(self):
        cnt = 0

        for root in self.ufs.get_roots():
            if not self.in_destroy(root):
                cnt += 1

        return cnt

    def add(self, i, x):
        if self.in_destroy(x):

            if i not in self.pairs_dict:
                self.pairs_dict[i] = 0
            if x not in self.destroy_dict:
                self.destroy[x] = []

            self.pairs[i] += 1
            self.destroy[x].append(i)

    def remove(self, x):
        self.destroy_set.remove(x)

        try:
            pair = self.destroy[x]
            self.pairs[pair] -= 1

            if self.pairs[pair] == 0:
                self.ufs.union(*self.pairs[pair])
        except:
            pass
        

if __name__ == '__main__':
    n, m = map(int, input().split())
    pairs = [tuple(int(x) + 1 for x in input().split()) for _ in range(m)]

    k = int(input())
    destroy = [int(input()) + 1 for _ in range(k)]

    ufs = UFS(n)
    stack = []

    record = Record(ufs, pairs, destroy)

    for i in range(m):
        a, b = pairs[i]

        if not record.in_destroy(a) and not record.in_destroy(b):
            ufs.union(a, b)
        
        record.add(i, a)
        record.add(i, b)

    stack.append(record.count())
    
    while destroy:
        x = destroy.pop()
        record.remove(x)
        stack.append(record.count())

    while stack:
        print(stack.pop())